-
Notifications
You must be signed in to change notification settings - Fork 213
feat: implement server versioning approach with semantic versioning support #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…upport This implements the versioning approach agreed upon in issue #158: ## Key Changes ### Documentation - Added comprehensive versioning guide (docs/versioning.md) - Updated FAQ with versioning guidance and best practices - Enhanced schema description with SHOULD recommendations ### Schema Updates - Added 255-character limit for version strings in schema.json - Enhanced version field description with semantic versioning guidance ### Implementation - New isSemanticVersion() function for proper semver detection - Enhanced compareSemanticVersions() with prerelease support - Implemented compareVersions() strategy: * Both semver: use semantic comparison * Neither semver: use timestamp comparison * Mixed: semver versions always take precedence - Updated publish logic to determine "latest" using new strategy - Added version length validation (255 char max) ### Versioning Strategy 1. Version MUST be string up to 255 characters 2. SHOULD use semantic versioning for predictable ordering 3. SHOULD align with package versions to reduce confusion 4. MAY use prerelease labels for registry-specific versions 5. Registry attempts semver parsing, falls back to timestamp ordering 6. Clients SHOULD follow same comparison logic Resolves #158 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: adam jones <[email protected]>
@claude I think the logic for ordering etc. shouldn't happen in database/memory.go - it should happen a layer higher at the service layer, not persistence layer. |
Claude finished @domdomegg's task —— View job Successfully moved version ordering logic from database layer to service layer! ✅ Tasks Completed:
SummarySuccessfully refactored the version ordering logic as requested: ✅ Created
✅ Updated
✅ Simplified
✅ All tests pass - No breaking changes to existing functionality The architecture now properly separates concerns:
|
- Move isSemanticVersion, compareSemanticVersions, and compareVersions functions from internal/database/memory.go to new internal/service/versioning.go - Update service layer to handle version comparison business logic - Simplify database layer to only handle persistence - All tests pass, maintaining existing functionality Co-authored-by: adam jones <[email protected]>
|
||
### For Non-Semantic Versions | ||
If version parsing as semantic version fails: | ||
- The registry will always mark the version as latest (overriding any previous version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels reasonable in isolation. but actually means that version
's total ordering is inconsistent with is_latest
, for packages with a mix of versions.
Not sure what is best to do here. Maybe this is fine. Maybe we should only update is_latest if it's now the latest in the total ordering spec below, idk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this behavior is necessary because the publisher does not indicate whether they are actually using semantic versioning. For example, if we said "semantic versions always take precedence", and a publisher is using non-semantic version numbers that sometimes appear to be semantic, then they are going to have a bad time. 😆
Unfortunately, as you noted, this means there is no natural sort order. Instead, we have to maintain an insertion order based on this logic.
|
||
### For Non-Semantic Versions | ||
If version parsing as semantic version fails: | ||
- The registry will always mark the version as latest (overriding any previous version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this behavior is necessary because the publisher does not indicate whether they are actually using semantic versioning. For example, if we said "semantic versions always take precedence", and a publisher is using non-semantic version numbers that sometimes appear to be semantic, then they are going to have a bad time. 😆
Unfortunately, as you noted, this means there is no natural sort order. Instead, we have to maintain an insertion order based on this logic.
🏠 Remote-Dev: homespace
🏠 Remote-Dev: homespace
🏠 Remote-Dev: homespace
🏠 Remote-Dev: homespace
Requesting review from @rdimitrov :) |
- Added versioning.go with semantic version comparison functions - Added versioning_test.go with comprehensive tests - Updated registry_service.go to validate version ordering on publish - Fixed nolint directives in publisher auth files :house: Remote-Dev: homespace
- Service layer determines if a version should be marked as latest - Database interface updated to accept isLatest parameter - UpdateLatestFlag method added for updating existing records - Memory and PostgreSQL implementations updated accordingly - Removed version comparison logic from database layer - All tests passing :house: Remote-Dev: homespace
- Database interface now accepts full RegistryMetadata object - More flexible for future extensions and metadata needs - Service layer creates and populates RegistryMetadata - Database implementations use provided metadata - Cleaner separation of concerns :house: Remote-Dev: homespace
- Service layer now generates the registry metadata ID - Database layer uses the provided ID instead of generating its own - Cleaner separation: service owns all business logic including ID generation - Database layer is purely for persistence :house: Remote-Dev: homespace
- Use registry metadata ID for both servers and server_extensions tables - Removes unnecessary serverID generation - Maintains 1:1 relationship between tables - Cleaner and more consistent with memory implementation :house: Remote-Dev: homespace
@claude can you review this? |
Claude finished @domdomegg's task —— View job Code Review SummaryComprehensive review of the versioning implementation with detailed feedback and recommendations. 🔍 Review Findings✅ Strengths
|
Response to Claude review:
|
…enhance tests 🏠 Remote-Dev: homespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks good 👍 I added a few comments but my main one is around the custom semver implementation (less code == less problems 😃)
@@ -0,0 +1,180 @@ | |||
package service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we consider using semver instead? It's from the official package - https://pkg.go.dev/golang.org/x/mod/semver and would save us from maintaining/testing that part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is probably better.
There are some Anthropic-internal reasons why I didn't do this initially, but realistically this is definitely the better approach.
existingTime, _ := time.Parse(time.RFC3339, server.RegistryMetadata.ReleaseDate) | ||
|
||
// Compare versions using the proper versioning strategy | ||
comparison := CompareVersions(newVersion, existingVersion, currentTime, existingTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we exit early here in case the request is trying to publish a version that is already there (which I think we don't want to allow) or older?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I think publishing old versions is fine, but publishing duplicate version is definitely a no-no. Fixing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
This implements the versioning approach agreed upon in issue #158:
Key Changes
Documentation
Schema Updates
Implementation
Versioning Strategy
Resolves #158
Generated with Claude Code